package acm.蓝桥4;

import java.util.Scanner;

public class 水体 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] arr = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = sc.nextInt();
        }
        while (m-- > 0) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            while (l <= r) {
                arr[l] = (int) (Math.log(arr[l])/Math.log(2) + 1);
                l++;
            }
            long res = 0;
            for (int i : arr) {
                res += i;
            }
            System.out.println(res);
        }
    }
}
